export default {
    state: {
    	// 登陆状态
    	loginStatus: JSON.stringify(uni.getStorageSync('loginStatus'))!=='{}'?uni.getStorageSync('loginStatus'):false,
		//token
		token:JSON.stringify(uni.getStorageSync('token'))!=='{}'?uni.getStorageSync('token'):'',
		//分享状态
		share_status:JSON.stringify(uni.getStorageSync('share_status'))!=='{}'?uni.getStorageSync('share_status'):false,
		//推荐人id
		share_user_id:JSON.stringify(uni.getStorageSync('share_user_id'))!=='{}'?uni.getStorageSync('share_user_id'):0,
		//推广的产品id
		share_product_id:JSON.stringify(uni.getStorageSync('share_product_id'))!=='{}'?uni.getStorageSync('share_product_id'):0,
		//扫码进小程序推广用户id
		promotionId:0,
		//手机号
		tel:'',
		isbuyer:uni.getStorageSync('isbuyer')!=''?uni.getStorageSync('isbuyer'):0,
		// 分享获取的值
		param:JSON.stringify(uni.getStorageSync('param'))!=='{}'&&uni.getStorageSync('param')!=''?uni.getStorageSync('param'):'{}'
		
    },
    mutations: {
    	// 改变登陆状态
    	changeLogin(state, status) {
    		state.loginStatus = status;
			//console.log(status)
			uni.setStorageSync('loginStatus',status)
    	},
		setToken(state,status){
			state.token = status;
			uni.setStorageSync('token',status)
		},
		setShareStatus(state,status){
			state.share_status = status;
			uni.setStorageSync('share_status',status)
		},
		setShareUserid(state,status){
			state.share_user_id = status;
			uni.setStorageSync('share_user_id',status)
		},
		setShareProductid(state,status){
			state.share_product_id = status;
			uni.setStorageSync('share_product_id',status)
		},
		setPromotionId(state,status){
			state.promotionId = status;
		},
		setTel(state,status){
			state.promotionId = status;
		},
		setIsbuyer(state,status){
			state.isbuyer = status;
		}
    },
    getters: {
    	// 获取登陆状态
    	loginStatus(state, getters) {
    		return state.loginStatus;
    	},
		// 获取token
		token(state, getters) {
			return state.token;
		},
		// 获取分享状态
		share_status(state, getters) {
			return state.share_status;
		},
		// 推荐人id
		share_user_id(state, getters) {
			return state.share_user_id;
		},
		// 推广的产品id
		share_product_id(state, getters) {
			return state.share_product_id;
		},
		promotionId(state, getters) {
			return state.promotionId;
		},
		tel(state, getters){
			return state.promotionId;
		},
		isbuyer(state, getters){
			return state.isbuyer;
		}
    },
	actions: {
	    changeLogin (context,state) {
	      context.commit('changeLogin',state)
	    },
		setToken (context,state) {
		  context.commit('setToken',state)
		},
		setShareStatus (context,state) {
		  context.commit('setShareStatus',state)
		},
		setShareUserid (context,state) {
		  context.commit('setShareUserid',state)
		},
		setShareProductid (context,state) {
		  context.commit('setShareProductid',state)
		},
		setPromotionId (context,state) {
		  context.commit('setPromotionId',state)
		},
		setTel(context,state) {
		  context.commit('setTel',state)
		},
		setIsbuyer(context,state) {
		  context.commit('setIsbuyer',state)
		}
		
		
		
	}	
}